package com.hqyj.springboot.springboot_multiple_order.service.impl;

import com.hqyj.springboot.springboot_multiple_order.mapper.OrderMapper;
import com.hqyj.springboot.springboot_multiple_order.service.OrderService;
import com.hqyj.springboot.springboot_multiple_payment.service.PaymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import pojo.Order;

@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper orderMapper;
    @Autowired
    private PaymentService paymentService;

    @Override
    @Transactional
    public boolean appendOrder(Order order) {
        boolean ben = false;
        int insertOrder = orderMapper.insertOrder(order);
        if (insertOrder > 0) {
            boolean appendPayment = paymentService.appendPayment(order);
            if (appendPayment) {
                ben = true;
            }
        }
        return ben;
    }
}
